require('./PageMaintaintable.styl');

const reactMixin = require('react-mixin');
const Actions = require('./actions');
const Store = require('./store');
import Maintainhighchart from 'components/maintainhighchart'
import Timerange from 'components/timerange'
const { Tab } = SaltUI;

class Maintaintable extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            
        };
    }
    chnangeEvent(startTime, endTime){
        Actions.fetch({startTime: startTime,endTime: endTime});
    }

    render() {
        var data={
            series:[{
                name: '故障次数',
                color: "#FFAA3C",
                data: this.state.falut_total
            }],
            categories: this.state.categories,
            show: true,
            percentage: false
        }
        var data1={
            series:[{
                name: '维保响应率',
                color: "#16B3F4",
                data: this.state.pesponse_rate
            }, {
                name: '维保有效率',
                color: "#03DB3B",
                data: this.state.effective_rate
            }],
            categories:this.state.categories,
            show: true,
            percentage: true
        }
        return (
            <div className="maintaintable">
                <Timerange onchange={this.chnangeEvent.bind(this)}/>
                <div className="list-tab">
                    <Tab active={this.state.active}  onChange={this.handleExchange}>
                        <Tab.Item title="故障统计">
                            <Maintainhighchart data={data}/>
                        </Tab.Item>
                        <Tab.Item title="响应率">
                            <Maintainhighchart data={data1}/>
                        </Tab.Item>
                    </Tab>
                </div>
            </div>
        );
    }

    componentWillMount() {}

    componentDidMount() {
        
    }

    componentWillReceiveProps(nextProps) {}

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {}

    componentDidUpdate(prevProps, prevState) {}

    componentWillUnmount() {}
}

reactMixin.onClass(Maintaintable, Reflux.connect(Store));

module.exports = Maintaintable;
